package database.auxiliary;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Calendar;

public class LogGenerator {
	
	public static void log(String info) {/*
		try {
			File logFile = new File("data/log.txt");
			if (!logFile.exists()) {
				logFile.createNewFile();
			}
			String content = "";
			String line = "";
			BufferedReader br = new BufferedReader(new FileReader(logFile));
			while ((line = br.readLine()) != null) {
				content += line + "\r\n";
			}
			br.close();

			Calendar time = Calendar.getInstance();
			String t = calendarToString(time);
			content += info + "  " + t + "\r\n";
			BufferedWriter bw = new BufferedWriter(new FileWriter(logFile));
			bw.write(content);
			bw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}*/
	}
	
	public static String calendarToString(Calendar c) {
		String year = String.valueOf(c.get(Calendar.YEAR));
		String month = String.valueOf(c.get(Calendar.MONTH) + 1);
		String date = String.valueOf(c.get(Calendar.DATE));
		String hour = String.valueOf(c.get(Calendar.HOUR_OF_DAY));
		String minute = String.valueOf(c.get(Calendar.MINUTE));
		String second = String.valueOf(c.get(Calendar.SECOND));
		return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
	}

}
